package com.tz.platform.tag.input;

import java.math.BigDecimal;
import java.text.DecimalFormat;

import com.tz.platform.tag.common.InfoTag;
import com.tz.platform.utils.DateUtil;
import com.tz.platform.utils.StringUtil;

/**
 * 用于页面上生成input的text框
 * ClassName: InputTextTag <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * date: 2016年5月23日 下午5:58:59 <br/>
 * @author changhz
 * @version
 */
@SuppressWarnings("serial")
public class InputOption extends InfoTag {

	private String dataMark; //操作符号
	private String dataGoal; //指定检索条件
	private String dataOptions; //操作符
	private String dateFormat;
	private String formatNumber;  //格式化数字
	private String devideFormatNumber; //是否格式化成万元

	public String getDateFormat() {
		return dateFormat;
	}
	public void setDateFormat(String dateFormat) {
		this.dateFormat = dateFormat;
	}
	public String getDataOptions() {
		return dataOptions;
	}
	public void setDataOptions(String dataOptions) {
		this.dataOptions = dataOptions;
	}
	public String getDataMark() {
		return dataMark;
	}
	public void setDataMark(String dataMark) {
		this.dataMark = dataMark;
	}
	public String getDataGoal() {
		return dataGoal;
	}
	public void setDataGoal(String dataGoal) {
		this.dataGoal = dataGoal;
	}
	public String getFormatNumber() {
		return formatNumber;
	}
	public void setFormatNumber(String formatNumber) {
		this.formatNumber = formatNumber;
	}
	public String getDevideFormatNumber() {
		return devideFormatNumber;
	}
	public void setDevideFormatNumber(String devideFormatNumber) {
		this.devideFormatNumber = devideFormatNumber;
	}

	@Override
	public String getTDContent() {
		StringBuffer strOut = new StringBuffer();
		if ( !StringUtil.msIsEmpty(getDataMark())) {
			strOut.append(" data-mark=\"" + getDataMark() + "\"");
		}
		if ( !StringUtil.msIsEmpty(getDataGoal())) {
			strOut.append(" data-goal=\"" + getDataGoal() + "\"");
		}
		if(StringUtil.msIsEmpty(this.getValue())){
			strOut.append("value=\"\"");
		}else{
			String value=this.getValue();
			if(!StringUtil.msIsEmpty(this.getDevideFormatNumber())){
				BigDecimal decimal=new BigDecimal(value);
				value=decimal.divide(new BigDecimal(10000)).toString();
			}else if(!StringUtil.msIsEmpty(this.getFormatNumber())){
				DecimalFormat df=new DecimalFormat("#,##0.00#");
				value=df.format(Double.valueOf(this.getValue()));
			}else if(!StringUtil.msIsEmpty(getDateFormat())){
				value = DateUtil.timeStampToStringDate(Long.valueOf(value), getDateFormat());
			}
			strOut.append("value=\""+value+"\"");
		}
		if ( !StringUtil.msIsEmpty(getDataOptions())) {
			strOut.append(" data-options=\"" + getDataOptions() + "\"");
		}
		
		return strOut.toString();
	}
	
	
	
}